home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacHack 1996
/
MacHack 1996.toast
/
Hacks
/
Hacks ’87
/
Source ƒ.sit
/
Source ƒ
/
C ƒ
/
CITADEL BBS 'C' SRC
/
CTDL.H
< prev
next >
Wrap
C/C++ Source or Header
|
1987-01-14
|
20KB
|
582 lines
/************************************************************************/
/* Ctdl.h */
/* #include file for all Citadel C files. */
/* Now includes only #defines and structs. */
/************************************************************************/
#define _C86_BIG 1
#include "stdio.h"
/************************************************************************/
/* 85Oct16 HAW Add code for OFFICE-STUFF parameter. */
/* 85Aug29 HAW Install code to allow double msg files for autobackup. */
/* 85Jun19 HAW Implant exit values so batch files can be made useful. */
/* 85May27 HAW Start adding networking gunk. */
/* 85May22 HAW MAXLOGTAB now sysop selectable. */
/* 85May06 HAW Add daily bailout parameter. */
/* 85May05 HAW Add SYSDISK parameter. */
/* 85Mar20 HAW Add timestamp code. */
/* 85Feb21 HAW Add directory names. */
/* 85Feb20 HAW Implement IMPERVIOUS flag. */
/* 85Feb18 HAW Insert global variables for baud search. */
/* 85Jan20 HAW Insert code to read from system clock. */
/* 84Aug30 HAW Begin conversion to MS-DOS */
/* */
/* #defines 82Dec10 dvm */
/* */
/* #defs supported in current system: */
/* */
/* #def FDC-1 for the TeleTek (dvm code) */
/* #def VFC-2 for the Big Board (dvm code) */
/* */
/* #def TEST for special small-scale test version */
/************************************************************************/
#define ulong unsigned long /* Makes it easier to format */
#define MSDOS 1
#define NAMESIZE 20 /* length of room names */
typedef char label[NAMESIZE];
/* Citadel programs use readSysTab() and writeSysTab() to write an */
/* image of the external variables in RAM to disk, and later restore */
/* it. The image is stored in ctdlTabl.sys . If ctdlTabl.sys is lost, */
/* confg.com will automatically reconstruct the hard way when invoked, */
/* and write a new ctdlTabl.sys out when finished. CtdlTabl.sys is */
/* always destroyed after reading, to minimize the possibility of */
/* reading an out-of-date version. In general, the technique works */
/* well and saves time and head-banging on bootup. You should, */
/* however, note carefully the following caution: */
/* o Whenever you change the declarations in Ctdl.h you should: */
/* --> destroy the current ctdlTabl.sys file */
/* --> recompile and reload all citadel programs which access */
/* ctdlTabl.sys -- currently citadel.com & configur.com */
/* --> use configur.com to build a new ctdlTabl.sys file */
/* */
/* If you ignore these warnings, little pixies will prick you in your */
/* sleep for the rest of your life. */
/************************************************************************/
/* Let's begin by defining the configuration struct. */
/* This is part of the contents of ctdltabl.sys */
struct config {
unsigned maxMSector; /* Max # of sectors (simulated) */
char megaHz; /* 8088 clock rate (for wait loops) */
ulong oldest; /* 32-bit ID# of first message in system*/
ulong newest; /* 32-bit ID# of last message in system*/
int nodeName; /* Offsets in codeBuf */
int nodeTitle;
int nodeId;
int bRoom;
int netPrefix, netSuffix;
char noChat; /* TRUE to suppress chat attempts */
int cryptSeed;
#ifndef MSDOS
char clock; /* TRUE if we have a hardware clock */
#endif
char search_baud; /* TRUE to do flip flop search for baud */
char IBM_or_clone; /* Specialize for Sperry PC <sigh> */
#define COMINT_VEC 12
int modem_status; /* Modem addresses */
int modem_data;
int line_status;
char dailyTimeout; /* Do we want to bail out on a daily */
int hourOut; /* basis? When? */
char call_log; /* if < 100, indicates drive for log */
char mirror; /* Auto backup of message files? */
char mbkpDisk; /* Where is this file located? */
char filter[128]; /* input character translation table */
char homeDisk, msgDisk, sysDisk;/* where we keep our data files */
char netDisk; /* where we want to find net files */
char ourDisk; /* where we are just now */
char ourUser[10];
char unlogEnterOk; /* TRUE if OK to enter messages anon */
char unlogReadOk; /* TRUE if unlogged folks can read mess */
char unlogLoginOk; /* TRUE if spontan. new accounts ok. */
char nonAideRoomOk; /* TRUE general folks can make rooms */
char noMail; /* TRUE if mail is not allowed */
char sysBaud;
char netParticipant; /* TRUE if participating in the net */
char longHaul; /* TRUE if willing to do long distance */
char dayDiv; /* Days to network on */
char netHour; /* Hour to start networking on */
char netLength; /* Length of networking */
int netSize;
int incomingHost;
int outcomingHost;
/* stuff to distinguish the various Citadel programs */
#define CITADEL 0 /* principal program */
#define xxxxx 1 /* unused */
#define NET 2 /* network downloader */
/*#define ARCHIVE 3 */ /* backup program (future) */
#define CONFIGUR 4
#define UTILITY 5
char weAre; /* set first thing by main() */
int paramVers;
/* Stuff to size system with: */
/* WARNING!!! if you expand MAXROOMS beyond 128, horrible, horrible */
/* things will happen to the userlog entries, which will no longer */
/* fit in the assigned 256-byte records and will overwrite things */
/* with normally undesirable results. 82Nov10CrT */
#define MAXROOMS 64 /* number of rooms allowed in system */
#define SHARED_ROOMS 10
int MAXLOGTAB; /* number of log entries supported */
/* Stuff nowadays usually in bdscio.h: */
/* values for functions to return: */
#define TRUE 1
#define FALSE 0
#define ERROR -1
#define SAMESTRING 0 /* value for strcmp() & friend */
/* ASCII characters: */
#define SOH 1
#define CNTRLC 3
#define EOT 4
#define ACK 6
#define BELL 7
#define BACKSPACE 8
#define CNTRLI 9 /* aka tab */
#define TAB 9 /* aka ^I */
#define NEWLINE 10 /* "linefeed" to philistines. */
#define CNTRLO 15
#define CNTRLl 12 /* Sysop privileges */
#define XOFF 19 /* control-s */
#define NAK 21
#define CAN 24
#define CNTRLZ 26
#define CPMEOF CNTRLZ
#define ESC 27 /* altmode */
#define CRC_START 'C'
#define DEL 0x7F /* delete char */
/* Stuff for rooms: */
#define LOBBY 0 /* Lobby> is >always< room 0. */
#define MAILROOM 1 /* Mail> is >always< room 1. */
#define AIDEROOM 2 /* Aide> is >always< room 2. */
#ifdef TEST
#define MSGSPERRM 58 /* should be >= MAILSLOTS */
#else
#define MSGSPERRM 58 /* roombuf must be 256 bytes or less. */
#endif
#define SECTSIZE 128
#define MAXCODE 512
unsigned char codeBuf[MAXCODE];/* buffer for configuration routines */
unsigned char scratch[40]; /* scratch space for config routines */
unsigned char shave[8]; /* shave-and-a-haircut/2 bits pauses */
/* routine offsets in codeBuf: */
int pBauds[4]; /* Indexes into here defined later */
int pHangUp, pCarrDetect, pMIReady, pMOReady, pInitPort;
int pCheckBaud;
#ifndef MSDOS /* MSDOS has and uses system clock, so if using */
/* it, don't need this stuff. */
int pInitDate, pGetDay, pGetMonth, pGetYear;
#endif
int catChar;
unsigned catSector;
char debug; /* turns debug printout on and off */
int sizeLTentry; /* contains size of a logTab entry */
char sysPassword[200]; /* Remote sysop */
} ; /* And that's all of the variables we want to save */
/************************************************************************/
/* Room data */
/************************************************************************/
#define MAXGEN 32 /* six bits of generation => 64 of them */
#define FORGET_OFFSET (MAXGEN / 2) /* For forgetting rooms */
#define LINNEW 0x0041 /* Only list unread rooms */
#define NORNEW 0x0051
#define NOROLD 0x0052 /* List both unread and read rooms */
/* List forgotten public rooms */
#define FGTRMS ((FORGET_OFFSET < 8) + 0x0000)
struct rflags { /* Room flags */
unsigned INUSE : 1; /* Room in use? */
unsigned PUBLIC : 1; /* Room public? */
unsigned MSDOSDIR : 1; /* Room directory? */
unsigned PERMROOM : 1; /* Room permanent? */
unsigned SKIP : 1; /* Room skipped? (temporary for user) */
unsigned UPLOAD : 1; /* Can room be uploaded to? */
unsigned DOWNLOAD : 1; /* Can room be downloaded from? */
unsigned SHARED : 1;
unsigned ARCHIVE : 1;
unsigned rflag3 : 1;
unsigned rflag4 : 1;
unsigned rflag5 : 1;
unsigned rflag6 : 1;
unsigned rflag7 : 1;
unsigned rflag8 : 1;
unsigned rflag9 : 1;
unsigned rflag10 : 1;
unsigned rflag11 : 1;
unsigned rflag12 : 1;
unsigned YUCK : 0; /* Force realignment I guess. */
} ;
struct rTable { /* The summation of a room */
unsigned char rtgen; /* generation # of room */
struct rflags rtflags; /* public/private flag etc */
label rtname; /* name of room */
ulong rtlastMessage;/* # of most recent message in room */
} ; /* And see ROOMA.C for declaration */
struct aRoom { /* The appearance of a room: */
unsigned char rbgen; /* generation # of room */
struct rflags rbflags; /* same bits as flags above */
label rbname; /* name of room */
char rbdisk; /* disk this rooms files are in 0=>none */
char rbdirname[9]; /* user directory for this room's files */
struct {
ulong rbmsgNo; /* every message gets unique# */
unsigned rbmsgLoc; /* sector message starts in */
} msg[MSGSPERRM];
} ; /* And see ROOMA.C for declaration */
/************************************************************************/
/* userlog stuff */
/************************************************************************/
#define CRYPTADD 117 /* */
struct lflags { /* Flags for person in log */
unsigned UCMASK : 1; /* Uppercase? */
unsigned LFMASK : 1; /* Linefeeds? */
unsigned EXPERT : 1; /* Expert? */
unsigned AIDE : 1; /* Vice-Grand-Poobah? */
unsigned L_INUSE : 1; /* Is this slot in use? */
unsigned TIME : 1; /* Send time to user of msg creation? */
unsigned OLDTOO : 1; /* Print out last oldmessage on <N>ew? */
unsigned NET_PRIVS : 1; /* User have net privileges? */
unsigned RUGGIE : 1; /* Juvenile? Future fun-ness */
unsigned lflag1 : 1;
unsigned lflag2 : 1;
unsigned lflag3 : 1;
unsigned lflag4 : 1;
unsigned lflag5 : 1;
unsigned lflag6 : 1;
unsigned lflag7 : 1;
unsigned lflag8 : 1;
unsigned lflag9 : 1;
unsigned YUCK : 0; /* Force realignment ??? */
} ;
#define MAILSLOTS 58 /* Same as normal room */
#define MAXVISIT 8 /* #visits we remember old newestLo for */
#define GENSHIFT 3 /* Where the generation # is */
#define CALLMASK 7 /* For finding last visit */
struct logBuffer { /* The appearance of a user: */
unsigned char lbnulls; /* #nulls, lCase, lFeeds */
struct lflags lbflags; /* UCMASK, LFMASK, EXPERT, AIDE, INUSE */
unsigned char lbwidth; /* terminal width */
char credit; /* Credit for long distance calls */
label lbname; /* caller's name */
label lbpw; /* caller's password */
unsigned char lbgen[MAXROOMS];/* 5 bits gen, 3 bits lastvisit */
ulong lbvisit[MAXVISIT];/* newestLo for this and 3 prev. visits */
unsigned lbslot[MAILSLOTS];/* for private mail */
ulong lbId[MAILSLOTS]; /* for private mail */
} ; /* And see LOG.C for declaration */
struct lTable { /* Summation of a person: */
int ltpwhash; /* hash of password */
int ltnmhash; /* hash of name */
int ltlogSlot; /* location in userlog.buf */
ulong ltnewest; /* last message on last call */
} ; /* And see LOG.C for declaration */
/************************************************************************/
/* terminal stuff */
/************************************************************************/
#define SPECIAL 27 /* <ESC> console escape char */
/************************************************************************/
/* message stuff */
/************************************************************************/
#define MAXTEXT 7500 /* maximum chars in edit buffer */
#define HELD 3
struct msgB { /* This is what a msg looks like */
int Ooops;
char mbtext[MAXTEXT] ; /* buffer text is edited in */
int mbheadChar ; /* start of message */
unsigned mbheadSector; /* start of message */
label mbauth ; /* name of author */
label mbdate ; /* creation date */
label mbtime ; /* creation time */
label mbId ; /* local number of message */
label mboname; /* short human name for origin system */
label mborig ; /* US xxx xxx xxxx style ID */
label mbroom ; /* creation room */
label mbsrcId; /* message ID on system of origin */
label mbto ; /* private message to */
label mbaddr ; /* address of system for net routing */
} ; /* declaration in MSG.C */
/* values for showMess routine */
#define NEWoNLY 0
#define OLDaNDnEW 1
#define OLDoNLY 2
#define GLOBALnEW 3
/************************************************************************/
/* modem stuff */
/************************************************************************/
#ifdef MSDOS
/* Interrupt constants */
#define INTA01 0x21 /* Interrupt controller */
#define EOI 0x20 /* End of Interrupt */
#endif
/* somestuff readfile() and sendfile() like: */
#define LOOPSPERSEC 5000
#define ERRORMAX 10
#define RETRYMAX 10
/* fiddle factor to timeout on no input: */
#define HITIMEOUT 7276 /* processor dependent, see MODEM.C */
#define NEWCARRIER 0x01 /* returned to main prog on login */
#define MODEM 0 /* current user of system is */
#define CONSOLE 1 /* one of these */
/* output XON/XOFF etc flag... */
#define OUTOK 0 /* normal output */
#define OUTPAUSE 1 /* a pause has been requested */
#define OUTNEXT 2 /* quit this message, get the next */
#define OUTSKIP 3 /* stop current process */
#define OUTPARAGRAPH 4 /* skip to next paragraph */
#define IMPERVIOUS 5 /* make current output unstoppable */
#define NEITHER 0 /* don't echo input at all */
#define CALLER 1 /* echo to caller only --passwords etc */
#define BOTH 2 /* echo to caller and console both */
#define NO_ECHO 0 /* Echo input as X's */
#define ECHO 1 /* Echo input (getString()) */
/* stuff for the mini-INTRPreter that drives the modem: */
/* opcodes for the interpreter: */
#define ANDI 1
#define INP 2
#define LOAD 3
#define LOADI 4
#define ORI 5
#define OUTP 6
#define OUTSTRING 7
#define PAUSEI 8
#define RET 9
#define STORE 10
#define XORI 11
#define STOREX 12
#define LOADX 13
#define OPRNUMBER 14
#define TOBDC 15
#define TODEC 16
/* For system calls. */
struct regval {int ax, bx, cx, dx, si, di, ds, es; };
#define STARTUP 1
#define FINISH 2
/************************************************************************/
/* net stuff */
/************************************************************************/
#define ONLY_300 0
#define BOTH_300_1200 1
#define TH_3_12_24 2
#define SetYourOwn 3
#define HANGUP 0
#define NORMAL_MAIL 1
#define R_FILE_REQ 2
#define A_FILE_REQ 3
#define NET_ROOM 5
#define CHECK_MAIL 6
#define ROLE_REVERSAL 201
#define BAD 0
#define GOOD 1
#define NO_ERROR 0 /* These refer to negative ack mail */
#define NO_RECIPIENT 1
#define BAD_FORM 2
#define UNKNOWN 99
struct nflags { /* Any and all reasons to call this node*/
unsigned normal_mail : 1;
unsigned in_use : 1;
unsigned room_files : 1;
unsigned local : 1;
unsigned flag1 : 1;
unsigned flag2 : 1;
unsigned flag3 : 1;
unsigned flag4 : 1;
unsigned flag5 : 1;
unsigned flag6 : 1;
unsigned flag7 : 1;
unsigned flag8 : 1;
unsigned flag9 : 1;
unsigned flag10 : 1;
unsigned flag11 : 1;
unsigned flag12 : 1;
unsigned flag13 : 1;
unsigned flag14 : 1;
unsigned flag15 : 1;
unsigned flag16 : 1;
unsigned realign : 0;
} ;
struct shared_room {
ulong lastMess;
unsigned srgen; /* High bit of gen is used flag */
unsigned srslot;
} ;
struct nodeRoomsTab {
struct shared_room rooms[SHARED_ROOMS];
} ;
struct netBuffer {
label netId;
label netName;
struct nflags nbflags;
char baudCode;
struct shared_room netRooms[SHARED_ROOMS];
} ;
struct netTable {
int ntnmhash;
int ntidhash;
struct nflags ntflags ;
} ;
struct cmd_data { /* Commands for networking */
unsigned char command;
char fields[4][NAMESIZE];
} ;
struct netMLstruct {
ulong ML_id;
unsigned ML_loc;
} ;
struct fl_req {
label room;
label roomfile;
char drive;
char path[100];
label filename;
} ;
/************************************************************************/
/* Exit values for errorlevels */
/************************************************************************/
#define SYSOP_EXIT 0
#define TIME_EXIT 1
#define CRASH_EXIT 2
#define REMOTE_SYSOP_EXIT 3
/************************************************************************/
/* Useful psuedo functions */
/************************************************************************/
#define gotCarrier() interpret(cfg.pCarrDetect)
#define onLine() (haveCarrier || onConsole)
#define wrNetId(x) ((strCmpU(x, ALL_LOCALS) != 0) ? x : WRITE_LOCALS)
#define zero_struct(x) setmem(&x, sizeof x, 0)
#define putMLNet(f,b) if (fwrite(&b, sizeof(b), 1, f) != 1)\
crashout("putMLNet crash")
#define getMLNet(f,b) (fread(&b, sizeof(b), 1, f) == 1)
#define TheSysop() (aide && onConsole)
#define copy_struct(src, dest) movmem(&src, &dest, sizeof src)
#define copy_array(src, dest) movmem(src, dest, sizeof src)
#ifndef NET_BUG
#define check() /* Null function -- real source is in the net source */
#else
#endif
#define needToCall(i) (netTab[i].ntflags.in_use == TRUE &&\
(netTab[i].ntflags.normal_mail == TRUE || netTab[i].ntflags.room_files == TRUE\
|| roomsShared(i)))
#define setNeedsProcessing(i) netBuf.netRooms[i].srslot |= 0x8000;
#define chkNeedsProcessing(i) (netBuf.netRooms[i].srslot & 0x8000)
#define resetNeedsProcessing(i) netBuf.netRooms[i].srslot &= 0x7FFF;
#define isSharedRoom(h, i) (sharedRoom[h].rooms[i].srgen & 0x8000)
#define resetNetRoomFlag(i) netBuf.netRooms[i].srgen &= 0x7FFF;\
sharedRoom[thisNet].rooms[(i)].srgen &= 0x7FFF;
#define netRoomSlot(i) (netBuf.netRooms[i].srslot & 0x7FFF)
#define netTabRoomSlot(h,i) (sharedRooms[h].rooms[i].srslot & 0x7FFF)
#define netGen(i) (netBuf.netRooms[i].srgen & 0x7FFF)
#define roomValidate(i) (roomTab[netRoomSlot(i)].rtgen == netGen(i))
#define INTERVALS 8 /* Half second intervals */
#define minimum(x,y) ((x) < (y) ? (x) : (y))
/************************************************************************/
/* Call log stuff */
/************************************************************************/
#define BAUD 0
#define L_IN 1
#define L_OUT 2
#define CARRLOSS 3
#define FIRST_IN 4
#define LAST_OUT 5
#define EVIL_SIGNAL 6
/************************************************************************/
/* Transfer protocol constants */
/************************************************************************/
#define WC_NONE 0
#define WC_NETWORK 1
#define WC_NORMAL 2
#define NORMAL 0
#define DISK 1